# Maintainer: Jelle van der Waa <jelle@archlinux.org>

pkgname=meilisearch
pkgver=1.5.0
pkgrel=1
pkgdesc="Lightning Fast, Ultra Relevant, and Typo-Tolerant Search Engine"
arch=(loong64 x86_64)
url="https://docs.meilisearch.com/"
license=('MIT')
depends=(gcc-libs)
makedepends=(rust)
options=(!lto)
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/meilisearch/MeiliSearch/archive/v${pkgver}.tar.gz
        ${pkgname}.service ${pkgname}.tmpfiles ${pkgname}.sysusers ${pkgname}.conf)
sha512sums=('32681ad6251a388b6886e93d9e814c7a25f20e905775c3d38c6f0bb2b1b5478129c5fe70530252c0d55d41961733c3311cc1e2cefa0319d04837819ba4083b1a'
            'dd936591833fa4ca4832e0574bdfcfd5ccfcbe1c794c6be2f6a5c9f8e4b9588a95b6da24d29ee533043dda200b37e67e3a8ba04339c1e7530a4c95e17ee14268'
            '76284bf4c436a6b3365edd6bd12ffcb186b721d284b29933e77ddc841d333be9eeb2701c89fba1567a8eedda52787be8d3c5f55809a051488b7295fbb6842bce'
            'b83518bd61cb587baac784b1b9bbe4a6a12be91c0a5b6cc0b3b631dde9cee1d59d6e43800a0d32b909fb2d90fe3f64e1ab63c3c8028428be3333d39f6c05d60c'
            '9d63a9cca6cafb248fffcd4a6e5bac0905d4b87f3eb9793576003d3965e35e217c4c1d6b3206b25ef47143e7d538e71c746bc0352bcdf248ed19e12f58aedc12')
validpgpkeys=()

build() {
  cd "$pkgname-$pkgver"
  cargo build --release --locked
}

check() {
  cd "$pkgname-$pkgver"
  ulimit -n 3000
  cargo test --release --locked
}

package() {
  cd "$pkgname-$pkgver"
  install -Dm 755 target/release/${pkgname} -t "${pkgdir}/usr/bin"
  install -D -m644 LICENSE "$pkgdir/usr/share/licenses/${pkgname}/LICENSE"

  install -D -m644 "${srcdir}/meilisearch.service"  "${pkgdir}/usr/lib/systemd/system/meilisearch.service"
  install -D -m644 "${srcdir}/meilisearch.sysusers" "${pkgdir}/usr/lib/sysusers.d/meilisearch.conf"
  install -D -m644 "${srcdir}/meilisearch.tmpfiles" "${pkgdir}/usr/lib/tmpfiles.d/meilisearch.conf"
  install -D -m644 "${srcdir}/meilisearch.conf" "${pkgdir}/etc//meilisearch.conf"
}
